
import { Mutation } from 'vuex';
import settings from '@/config/settings';

export interface StateType {
    // 左侧展开收起
    collapsed: boolean;
    // 顶部菜单开启
    topNavEnable: boolean;
    // 头部固定开启
    headFixed: boolean;
}

export interface ModuleType {
    namespaced: true;
    name: string;
    state: StateType;
    mutations: {
        changeLayoutCollapsed: Mutation<StateType>;
        setTopNavEnable: Mutation<StateType>;
        setHeadFixed: Mutation<StateType>;
    };
    actions: {
    };
}

const initState: StateType = {
    collapsed: false,
    topNavEnable: settings.topNavEnable,
    headFixed: settings.headFixed,
};

const StoreModel: ModuleType = {
    namespaced: true,
    name: 'global',
    state: {
        ...initState
    },
    mutations: {
        changeLayoutCollapsed(state, payload) {
            // debugger
            state.collapsed = payload;
        },
        setTopNavEnable(state, payload) {
            state.topNavEnable = payload;
        },
        setHeadFixed(state, payload) {
            state.headFixed = payload;
        }
    },
    actions: {}
}



export default StoreModel;
